package com.huafeng.serviceutil.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 花风
 * @date 2023/8/15 20:13
 * @Description Swagger配置
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket docket(){
       return new Docket(DocumentationType.SWAGGER_2)
               .groupName("adminApi")
               .apiInfo(new ApiInfoBuilder()
                       .title("后台管理系统-API文档")
                       .description("本文档描述了后台管理系统接口定义")
                       .version("1.0")
                       .contact(new Contact("huafeng","http://huafeng.com","huafeng@qq.com"))
                       .build())
               .select()
               .apis(RequestHandlerSelectors.basePackage("com.huafeng"))
               //只显示admin路径下的页面
               .paths(PathSelectors.regex("/admin/.*"))
               .build();
    }
}
